﻿using AxeFrog.Data;

namespace AxeFrog.Security.Data
{
	public interface IUserRepository : IRepository<User, long>
	{
		void NotifyUserAccess(User user);
		User GetByUsername(string username);
		User GetByEmail(string email);
		DataPage<User> List();
		DataPage<User> List(UserQueryOptions options);

		int CountNewUsers(int days);
		int CountUsersInRole(long role);
		int CountUsers();

		bool CheckForOtherUserByName(string name, long currentUserID);
		bool CheckForOtherUserByEmail(string email, long currentUserID);
		bool CheckForOtherUserByUsername(string username, long currentUserID);
	}

	public class UserQueryOptions
	{
		public bool? Deleted { get; set; }
		public string Search { get; set; }
		public int? PageSize { get; set; }
		public int? PageNumber { get; set; }
		public UserQueryOrderBy OrderBy { get; set; }
		public bool OrderByAscending { get; set; }

		public UserQueryOptions()
		{
			OrderByAscending = true;
			OrderBy = UserQueryOrderBy.ID;
			Deleted = false;
		}
	}

	public enum UserQueryOrderBy
	{
		ID = 1,
		Name = 2,
		Username = 3,
		Email = 4,
		DateCreated = 4
	}
}